<template>
	<el-dialog draggable v-model="dialogShow" width="60%" @close="onClose">
		<el-table :data="tableData.data" @selection-change="(selection:any[])=>tableData.selection=selection">
			<el-table-column type="index" label="序号" width="60" />
			<el-table-column prop="SysCreateTime" label="运行时间"> </el-table-column>
			<el-table-column prop="Status" label="运行结果">
				<template #default="scope">
					<el-tag type="success" v-if="scope.row.Status=='10'">成功</el-tag>
					<el-tag type="info" v-else>失败</el-tag>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			background
			small
			class="page"
			layout="prev, pager, next"
			:current-page="formData.PageIndex"
			:page-size="formData.PageSize"
			:total="tableData.total"
			@current-change="onPage"
		>
		</el-pagination>
	</el-dialog>
</template>

<script setup lang="ts">
import { Ref,ref } from 'vue';
import { Post } from '/@/common/http';
const dialogShow = ref(false);
const tableData: Ref = ref({
	data: [],
	selection: [],
	total: 0,
});
const formData = ref({
	PageIndex: 1,
	PageSize: 50,
	TaskId: 0,
});
const loadData = () => {
	Post('SysTask/GetTaskLogs', formData.value, (res: any) => {
		tableData.value.data = res.Data.Data;
		tableData.value.total = res.Data.DataCount;
	});
};
const onShow = (taskId: number) => {
	dialogShow.value = true;
	formData.value.TaskId = taskId;
	if (taskId > 0) {
		loadData();
	}
};
const onClose = () => {
	tableData.value.data = [];
	tableData.value.selection = [];
	formData.value.TaskId = 0;
	dialogShow.value = false;
};
const onPage = (pageIndex: number) => {
	formData.value.PageIndex = pageIndex;
	loadData();
};
defineExpose({
	onShow,
});
</script>
